const Androiddownload = "https://downloads.qn1000a.com/apk/qnbox/千年游戏盒子_v1.4.3.apk";
const Androidbag = "com.hygame.qnboxaz3://";
const iosbag = "com.qnhz.yxhk4://";

const iosdownloadpc = "https://apps.apple.com/cn/app/%E5%8D%83%E6%B8%B8%E7%A4%BE%E5%8C%BA/id6475273179";

function downloadA(url, target = '_blank') {
    const dowa = document.createElement('a');
    dowa.href = url;
    dowa.target = target;
    document.body.appendChild(dowa);
    dowa.click();
    document.body.removeChild(dowa);
}

function callApp(schema, timeOut) {
    let timer, start = new Date().getTime();
    let myPromise = new Promise((resolve, reject) => {
        window.location.href = schema;
        window.addEventListener('visibilitychange', () => {
            if (document.visibilityState === 'hidden') {
                clearTimeout(timer);
                resolve();
            };
        });
        timer = setTimeout(() => {
            let end = new Date().getTime();
            if (end - start > timeOut + 1000) {
                clearTimeout(timer);
                resolve();
            } else {
                reject();
            };
        }, timeOut);
    })
    return myPromise
}

function mylocation(url) {
    window.location.href = url;
}
